package com.rykj.qxj.test.xtest;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Locale;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.rykj.qxj.result.BaseResponse;
import com.rykj.qxj.result.ErrType;

public class JsonArray {

	public static void main(String[] args) throws ParseException {
		// TODO Auto-generated method stub
		//[{"Safari":55,"Chrome":56,"其他":36,"Edge":102,"Opera":26,"Firefox":36}]
		/*JSONArray jsa=new JSONArray();
		
		JSONObject jb=new JSONObject();
		jb.put("Safari", 23);
		jb.put("Chrome", 56);
		jb.put("Edge", 2);
		jb.put("Opera", 56);
		jb.put("Firefox", 78);
		jb.put("Other", 23);
		jsa.add(jb);
		System.out.println(jsa);*/
		
//		String url="/weather-api/data-api/subject/getsky";
//		String subSequence = (String) url.subSequence(0, url.indexOf('?'));
//		System.out.println(subSequence);
		
		/*SimpleDateFormat formatter = new SimpleDateFormat("dd/MMM/yyyy:hh:mm:ss", Locale.ENGLISH);
		Date date = formatter.parse("15/Aug/2019:20:12:22");
		SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		System.out.println("转换后的日期格式："+format.format(date));*/
		
		//String str="www.imysd.com dd  dd  ee ff  gg zz";
		//System.out.println(str.indexOf("zz"));
		
		Student st=new Student();
		st.setId(1);
		st.setName("张三");
		st.setAge(23);
		
		Student st1=new Student();
		st1.setId(11);
		st1.setName("张三1");
		st1.setAge(231);
		
		List<Student> stus=new ArrayList<Student>();
		stus.add(st);
		stus.add(st1);
		
		BaseResponse baseResponse = new BaseResponse(ErrType.SUCCESS.getCode(), ErrType.SUCCESS.getMessage(), stus);
		System.out.println(baseResponse.toString());
		String jsonString = JSON.toJSONString(baseResponse,SerializerFeature.WriteNonStringValueAsString);
		System.out.println(jsonString);

	}

}
